// pages/mypage/invoicehistory/invoicehistory.js
const request = require('@/utils/request.js')
const constants = require('@/utils/khyConstants.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dataList: [],
    invoiceStatusList: getApp().globalData.dictData['invoiceStatus'],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getPageData()
  },

  getPageData() {
    let user = getApp().getUserInfo()
    request.get('/UserController/getUserOrderInvoice', {userNo: user.userNo}).then(res => {
      if (res.data.code == constants.resultSuccessCode
        && res.data.result) {
          let data = res.data.result || []
          this.setData({
            dataList: data,
          })
      }
    })
  },

  invoice(e) {
    let order = e.currentTarget.dataset.order
    if (order) {
      let data = {}
      data.type='2'
      data.keyId = order.keyId
      data.packageNo = order.packageNo
      getApp().globalData.pageData[constants.page_invoice] = data
      wx.navigateTo({
        url: '/pages/mypage/invoice/invoice',
      })
    }
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})